import axios from "axios"
import nprogress from "nprogress"
import "nprogress/nprogress.css"

const mockAjax = axios.create({
    baseURL:'/mock',
    timeout: 8000,
})

// 请求拦截
mockAjax.interceptors.request.use( (config)=> {
    nprogress.start()
    return config
    
});

// 响应拦截
mockAjax.interceptors.response.use((response)=>{
    nprogress.done()
    return response.data;
   
},  (error)=>{
    return Promise.reject(error)
});

export default mockAjax